package khfx.dao.db;

import java.util.ArrayList;

public class CriteriaAndOr implements Criteria {
	Criteria left = null;
	Criteria right = null;
	String relation = null;
	ArrayList<Criteria> adds = new ArrayList<Criteria>();

	public CriteriaAndOr(String relation, Criteria a, Criteria b) {
		this.relation = relation;
		this.left = a;
		this.right = b;
	}

	public void addCriteria(Criteria c) {
		adds.add(c);
	}


	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(" ( ");
		sb.append(left.toString());
		sb.append(" ");
		sb.append(relation);
		sb.append(right);
		sb.append(")");
		for(int i=0;i<adds.size();i++) {
			sb.append(" and ");
			sb.append(adds.get(i).toString());
		}
		return sb.toString();
	}

}
